Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Fix "weave ps" #2418

Merged
merged 4 commits into from
Jul 12, 2016
Merged

Fix "weave ps" #2418

merged 4 commits into from
Jul 12, 2016

Conversation

brb
Copy link
Contributor

@brb brb commented Jul 4, 2016

This PR fixes the problem described in #2388. In addition, the PR optimizes the GetBridgeNetDevs and containerAddrs functions.

Keep in mind, that the fix is specific for this case, because we move all the code depending on a non-host netns to the bottom of containerAddrs instead of making WithNetNS safe.

To address the safety problem, I've filed #2419 .

Fixes #2388.

@bboreham bboreham self-assigned this Jul 5, 2016
func GetBridgeNetDev(bridgeName string) (NetDev, error) {
var netdev NetDev

err := weavenet.WithNetNSLinkByPid(1, bridgeName, func(link netlink.Link) error {

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@bboreham bboreham assigned brb and unassigned bboreham Jul 5, 2016

containers := make(map[string]*docker.Container)
for _, cid := range containerIDs {
if containers[cid], err = client.InspectContainer(cid); err != nil {

This comment was marked as abuse.

This comment was marked as abuse.

return common.GetBridgeNetDev(bridgeName)
}

container, err := c.InspectContainer(containerID)

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

brb added 4 commits July 5, 2016 15:12
- Optimize. Use LinkByName instead of iterating over list of available
  links. Linux does not support interfaces with the same names.
- Remove unnecessary indirection in utility functions which return
  common.NetDev.
Make sure that any network namespace changes happens at the end of
the cmd invocation. Otherwise, we are risking to end up in a situation
in which OS scheduling threads are in a "wrong" namespace.

See WithNetNS for more details.
- Do not re-enter the root netns when querying weave bridge.
- Enter the root netns when constructing the predicate.
@brb brb assigned bboreham and unassigned brb Jul 5, 2016
indexes := make(map[int]struct{})

// Scan devices in root namespace to find those attached to weave bridge
err := weavenet.WithNetNSLinkByPidUnsafe(1, bridgeName,

This comment was marked as abuse.

This comment was marked as abuse.

@bboreham
Copy link
Contributor

LGTM assuming my questions for clarification come out the way I think.

@bboreham bboreham assigned brb and unassigned bboreham Jul 11, 2016
@brb brb assigned bboreham and unassigned brb Jul 11, 2016
@bboreham bboreham added this to the 1.6.1 milestone Jul 12, 2016
@bboreham bboreham merged commit c1483db into 1.6 Jul 12, 2016
brb added a commit that referenced this pull request Jul 14, 2016
The #2418 has changed a behaviour of "weave ps" which outputs
"Link not found" when weave is not running. The previous
behaviour was to output an empty line.
brb added a commit that referenced this pull request Jul 14, 2016
The #2418 has changed a behaviour of "weave ps" which outputs
"Link not found" in the case of weave not running. The previous
behaviour was to output an empty line.
@bboreham bboreham deleted the issues/2388-weave-ps branch November 9, 2016 17:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants